<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title></title>
	<script src="vue.js"></script>
</head>

<body>
	<div id="app">
		<div>
			a的值{{a}}
		</div>
		<div>
			<button type="button" @click="add">点我加1</button>
		</div>
	</div>
	<script>
		var app = new Vue({
			el: "#app",
			data: {
				a: 1
			},
			methods: {
				add() {
					this.a++;
				}
			},
			computed: {}
		});
		app.$watch("a", function (newVal, oldVal) {
			console.log("新值:", newVal, "上一次的值:", oldVal);
		})
	</script>
</body>

</html>